#ifndef WORLD_H
#define WORLD_H

#include <QDeclarativeItem>
#include <QVariant>
#include <QRect>

#include "GEAudioMixer.h"
#include "GEAudioOut.h"
#include "GEInterfaces.h"
#include "GEAudioBuffer.h"

class World : public QDeclarativeItem
{
    Q_OBJECT
public:
    explicit World(QDeclarativeItem *parent = 0);
    ~World();

    Q_INVOKABLE QVariant checkGroundCollision(QDeclarativeItem *item) const;
    Q_INVOKABLE QVariant checkObjectCollision(QDeclarativeItem *item) const;
    Q_INVOKABLE QRect intersectedRect(QDeclarativeItem *item1, QDeclarativeItem *item2) const;

    GE::AudioMixer &getMixer() { return m_audioMixer; }

    GE::AudioBuffer *addAudio(QString source);

private:
    QVariant checkCollision(QDeclarativeItem *item, bool solid) const;
    void stopAudio();

    GE::AudioOut *m_audioOutput;
    GE::AudioMixer m_audioMixer;
};

// this is necessary to convert the QList to QVariant in order to pass it on to QML
Q_DECLARE_METATYPE(QList<QObject *>)

#endif // WORLD_H
